home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_MENU.TXT < prev    next >
Encoding:
Text File  |  1992-12-22  |  10.1 KB  |  268 lines

  1. '
  2. 'Class description:
  3. '
  4. !short:Menu class structure:
  5. Class Menu:
  6. ~~~~~~~~~~~~
  7. Makes all the main menu functions.
  8.  
  9. Common use:
  10. ~~~~~~~~~~~
  11. It is as example used in DEMO1.prg and DEMO2.prg.
  12.  
  13. Zdrojovy text triedy Menu je v subore C_Menu.prg
  14. Source code is in C_Menu.prg.
  15.  
  16. !seealso: c_md.ngo:MD c_view.ngo:View c_dbf.ngo:Dbf c_color.ngo:Color ob_class.ngo:"Class hierarchy"
  17.  
  18. !short:~~~~~~~~~~~~~~~~~~~~~
  19. !short:create class Menu
  20. !short:  export:
  21. !short:  var Color   //m->Color:Menu
  22. ^BMenu:Color^N: public: character
  23.   Menu color definition.
  24.  
  25. !short:  var Data    //{}
  26. ^BMenu:Data^N: read-only: array
  27.   N-dimensional array for storing of the objects of the class MD,
  28.   it describes the whole menu structure.
  29.  
  30. !short:  var Block   //{}
  31. ^BMenu:Block^N: read-only: array
  32.   Onedimensional array for storing of the code blocks, which are
  33.   to be processed when user selects a menu action.
  34.  
  35. !short:  var Avail   //{}
  36. ^BMenu:Avail^N: read-only: array
  37.   Onedimensional array storing the logical value true or false about the
  38.   selectability of the menu item.
  39.  
  40. !short:  var HotKeys //{}
  41. ^BMenu:HotKeys^N: read-only: array
  42.   Acclerator array, here are the "hot keys" stored for speeding up the
  43.   menu items selection. It structure is:
  44.   HotKeys:={}
  45.   AAdd( HotKeys, {nKey,nIdx} )
  46.   ...
  47.   Where:
  48.   nKey is InKey hot key code.
  49.   nIdx is the Menu:Block pointer to desired action.
  50.  
  51. !short:  var Idx     //1
  52. ^BMenu:Idx^N: read-only: numeric
  53.   The last selected item of the top menu level (bar pointer).
  54.  
  55. !short:  var NewTask //nil
  56. ^BMenu:NewTask^N: public: object_of_task
  57.   Selects the next task for the Esc user exit. This instvar variable
  58.   should content the class Task object or its successor. If there is
  59.   no need to start a special task the instvar variable NewTask can be nil.
  60.  
  61. !short:  method New=MenuNew          //o:New() --> self
  62. ^BMenu:New()^N: public: return self
  63.   Object is filled with the default values.
  64.  
  65. !short:  method Init=MenuInit        //o:Init() --> true
  66. ^BMenu:Init()^N: public: return true
  67.   The menu object initialization and (may) the opened files reindex
  68.   (only if it is need, i.e. if previous running copy of the program
  69.   was be crashed).
  70.  
  71. !short:  method Password=MenuPassword//o:Password(SelfID) --> true
  72. ^BMenu:Password(SelfID)^N: public: return true
  73.   Enables the password change. If the user has supervisor rights, he can
  74.   change all paswords. He can add the name, password and rights for the
  75.   next user or delete the user.
  76.  
  77.   Parameter description:
  78.   ~~~~~~~~~~~~~~~~~~~~~
  79.   ^USelfID^N: numeric
  80.    Pointer to object of class MD for recursive restart of this method.
  81.  
  82. !short:  method AddBar=MenuAddBar    //o:AddBar(cName,bAction,bPreBlock,bPostBlock) --> true
  83. ^BMenu:AddBar(cName,bAction,bPreBlock,bPostBlock)^N: public: return true
  84.   Next item to bar line of the menu (the top line) is added. For every item
  85.   is created a hot key after the character marked with ~ prefix.
  86.  
  87.   Parameter description:
  88.   ~~~~~~~~~~~~~~~~~~~~~~
  89.   ^UcName^N: character: no default
  90.    Menu item name
  91.  
  92.   ^UbAction^N: code_block: default is the submenu for this item
  93.    The code block, if not defined, the submenu for this bar item is created,
  94.    if defined it represents the action processed when this item is selected.
  95.  
  96.   ^UbPreBlock^N: code_block: default is {||true}
  97.    The code block, processedd before entering this item.
  98.  
  99.   ^UbPostBlock^N: code_block: default is {||true}
  100.    The code block processed imediately after leaving the item.
  101.  
  102. !short:  method AddMenu=MenuAddMenu  //o:AddMenu(cName,nHotKey,bPreBlock,bPostBlock) --> true
  103. ^BMenu:AddMenu(cName,nHotKey,bPreBlock,bPostBlock)^N: public: return true
  104.   The current menu is appended with the next submenu item.
  105.  
  106.   Parameter description:
  107.   ~~~~~~~~~~~~~~~~~~~~~~
  108.   ^UcName^N: character: no default
  109.    Menu item name.
  110.  
  111.   ^UnHotKey^N: numeric: no default
  112.    It is InKey() key code, representing the "hot key" for this menu item.
  113.    If not set the hot key is not created.
  114.  
  115.   ^UbPreBlock^N: code_block: default is {||true}
  116.    The code block, processed before entering this item.
  117.  
  118.   ^UbPostBlock^N: code_block: default is {||true}
  119.    The code block processed imediately after leaving the item.
  120.  
  121. !short:  method AddItem=MenuAddItem  //o:AddItem(cName,bAction,nHotKey,bPreBlock,bPostBlock) --> true
  122. ^BMenu:AddItem(cName,bAction,nHotKey,bPreBlock,bPostBlock)^N:
  123.   public: return true
  124.   The current menu is appended with the next item, representing the action
  125.   to be done when selecting this menu item.
  126.  
  127.   Parameter description:
  128.   ~~~~~~~~~~~~~~~~~~~~~~
  129.   ^UcName^N: character: no default
  130.    Menu item name
  131.  
  132.   ^UbAction^N: code_block: no default
  133.    The code block processed as the action when selecting this menu item.
  134.    As parameter becomes the pointer to MD structure, which is the menu item
  135.    stored in.
  136.  
  137.   ^UnHotKey^N: numeric: no default
  138.    It is InKey() key code, representing the "hot key" for this menu item.
  139.    If not set the hot key is not created.
  140.  
  141.   ^UbPreBlock^N: code_block: default je {||true}
  142.    The code block, processed before entering this item.
  143.  
  144.   ^UbPostBlock^N: code_block: default je {||true}
  145.    The code block processed imediately after leaving the item.
  146.  
  147. !short:  method AddCheck=MenuAddCheck//o:AddCheck(cName,bAction,nHotKey,bPreBlock,bPostBlock) --> true
  148. ^BMenu:AddCheck(cName,bAction,nHotKey,bPreBlock,bPostBlock)^N:
  149.   public: return true
  150.   The same as AddItem, but operates as switch, not as the common menu item.
  151.   The bAction prameter is a Get/Set block for reading the switch value (when
  152.   used without the parameters), or for setting the value of the switch (when
  153.   using the new value as the parameter)
  154.  
  155. !short:  method AddView=MenuAddView  //o:AddView(cName,cWinName,oV,nHotK,nVk,nEk,nGk,nLk,nIk,nFk,nRk,nMk) --> true
  156. ^BMenu:AddView(cName,cWinName,oV,nHotKey,nVk,nEk,nGk,nIk,nFk,nRk,nMk)^N:
  157.   public: return true
  158.   The menu is appended with a complex menu structure dealing the single
  159.   View object.
  160.  
  161.   Parameter description:
  162.   ~~~~~~~~~~~~~~~~~~~~~
  163.   ^UcName^N: character: no default
  164.    Menu item name
  165.  
  166.   ^UcWinName^N: character: no default
  167.    Displayed object window title.
  168.  
  169.   ^UoV^N: object_of_view: no default
  170.    The view object.
  171.  
  172.   ^UnHotKey^N: numeric: no default
  173.    InKey() code of hot key for this view object.
  174.  
  175.   ^UnVk^N: numeric: no default
  176.    InKey() code of hot key for the item "View" of this view object.
  177.  
  178.   ^UnEk^N: numeric: no default
  179.    InKey() code of hot key for the item "Edit" of this view object.
  180.  
  181.   ^UnGk^N: numeric: no default
  182.    InKey() code of hot key for the item "Goto" of this view object.
  183.  
  184.   ^UnIk^N: numeric: no default
  185.    InKey() code of hot key for the item "Index" of this view object.
  186.  
  187.   ^UnFk^N: numeric: no default
  188.    InKey() code of hot key for the item "Filter" of this view object.
  189.  
  190.   ^UnRk^N: numeric: no default
  191.    InKey() code of hot key for the item "Report" of this view object.
  192.  
  193.   ^UnMk^N: numeric: no default
  194.    InKey() code of hot key for the item "Modify" of this view object.
  195.  
  196. !short:  method PopSubLevel=MenuPopSubLevel   //o:PopSubLevel() --> true
  197. ^BMenu:PopSubLevel()^N: public: return true
  198.   This method use when you want in generated menu structure to return one
  199.   level up and to continue there in appending the menu items.
  200.  
  201. !short:  method DisableItem=MenuDisableItem   //o:DisableItem(nItemID,lSubMenu) --> true
  202. ^BMenu:DisableItem(nItemID,lSubMenu)^N: public: return true
  203.   The menu item (pointed to with the nItemID pointer) selection is disabled.
  204.   All code blocks are passed to nItemID, which is the offset to internal
  205.   table of flags which indicates the recursive entering of the menu item.
  206.  
  207.   Parameter description:
  208.   ~~~~~~~~~~~~~~~~~~~~~~
  209.   ^UnItemID^N: numeric: no default
  210.    Menu item pointer.
  211.  
  212.   ^UlSubMenu^N: logical: default is true
  213.    If true, disabled are all items below the current item (it can have
  214.    submenu selectable by hot key). If false, only the current item is
  215.    selected.
  216.  
  217. !short:  method EnableItem=MenuEnableItem     //o:EnableItem(nItemID,lSubMenu) --> true
  218. ^BMenu:EnableItem(nItemID,lSubMenu)^N: public: return true
  219.   The same as Menu:DisableItem(), but instead of disabling the item it is
  220.   enabled.
  221.  
  222. !short:  method GetMD=MenuGetMD               //o:GetMD(nItemID) --> object_of_MD
  223. ^BMenu:GetMD(nItemID)^N: public: return object_of_MD
  224.   The current menu item identifier is searched for its data structure
  225.   (the class MD object).
  226.  
  227. !short:  method GetParentMD=MenuGetParentMD   //o:GetParentMD(nItemID) --> object_of_MD
  228. ^BMenu:GetParentMD(nItemID)^N: public: return object_of_MD
  229.   The same as Menu:GetMD(), but the parent data structure is searched.
  230.  
  231. !short:  method Process=MenuProcess           //o:Process() --> true
  232. ^BMenu:Process()^N: public: return true
  233.   The main program body, can be finished only by processing of the method
  234.   Menu:Done().
  235.  
  236. !short:  method BarEntry=MenuBarEntry         //o:BarEntry(aAccelerators) --> true
  237. ^BMenu:BarEntry(aAccelerators)^N: private: return true
  238.   Internal method processed by the menu. aAccelerators is the array of
  239.   InKey() codes, for speeding up the user access to the required menu item.
  240.   The every processing of this method takes the first item, which is inserted
  241.   as the key to the keyboard queue.
  242.  
  243. !short:  method ItemEntry=MenuItemEntry       //o:ItemEntry(MD,CurSize,aAccelerators) --> true
  244. ^BMenu:ItemEntry(MD,CurSize,aAccelerators)^N:  private: return true
  245.   Internal method by which is the submenu processed when the user selects
  246.   the item. This method is often processed recursive (by submenus).
  247.  
  248.   Parameter description:
  249.   ~~~~~~~~~~~~~~~~~~~~~~
  250.   ^UMD^N: object_of_MD: no default
  251.    Submenu for this method (to be processed), its data structure is MD.
  252.    The processing is to display the submenu and to select the item by
  253.    the user.
  254.  
  255.   ^UCurSize^N:
  256.    The item width of current submenu.
  257.  
  258.   ^UaAccelerators^N: array: default is {}
  259.    The same as in BarEntry() method.
  260.  
  261. !short:  method Done=MenuDone                 //o:Done(lConfirm) --> true
  262. ^BMenu:Done(lConfirm)^N:  public: return true
  263.   It ends the main program cycle (the whole program).
  264.   It is activated mainly as an menu item.
  265.  
  266. !short:  endclass
  267.  
  268.